//
//  YLMessageCenterController.m
//  YLFinanceService
//
//  Created by she1323 on 2017/9/2.
//  Copyright © 2017年 she1323. All rights reserved.
//

#import "YLMessageCenterController.h"
#import "XXPageTabView.h"
#import "XXPageTabItemLable.h"
#import "YLGlobeHeader.h"
#import "YLMessageBaseViewController.h"
@interface YLMessageCenterController ()<XXPageTabViewDelegate>
@property (nonatomic, strong) XXPageTabView *pageTabView;
@end

@implementation YLMessageCenterController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"消息中心";
    [self setUpPageTabView];
    
    if (@available(iOS 11.0, *)) {
        self.pageTabView.tabView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentAlways;//UIScrollView也适用
    }
    
    
    // Do any additional setup after loading the view.
}
    

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
//    self.automaticallyAdjustsScrollViewInsets = NO;
    
 
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    self.navigationController.navigationBar.translucent = NO;
}

- (void)setUpPageTabView
{
    self.navigationController.navigationBar.translucent = YES;
    YLMessageBaseViewController *vc1 = [[YLMessageBaseViewController alloc] init];
    vc1.messageType = YLMessageTypeNotice;
    YLMessageBaseViewController *vc2 = [[YLMessageBaseViewController alloc] init];
    vc2.messageType = YLMessageTypeAnnouncement;
    
    [self addChildViewController:vc1];
    [self addChildViewController:vc2];
    
    CGFloat statusBarH = [UIApplication sharedApplication].statusBarFrame.size.height;
    CGFloat y = self.navigationController.navigationBar.frame.size.height + statusBarH;
    //支持网易云音乐，今日头条，微博等切换栏效果
    self.pageTabView = [[XXPageTabView alloc] initWithChildControllers:self.childViewControllers childTitles:@[@"通知", @"公告"]];
    self.pageTabView.frame = CGRectMake(0, y, self.view.frame.size.width, self.view.frame.size.height - y);
    self.pageTabView.tabSize = CGSizeMake(YLScreenW, 44.0f);
    self.pageTabView.selectedColor = YLLOrgColor;
    self.pageTabView.separatorColor = YLColor(200, 200, 200);
    self.pageTabView.unSelectedColor = YLLineColor;
    self.pageTabView.delegate = self;
    self.pageTabView.indicatorHeight = 1.5;
    self.pageTabView.titleStyle = XXPageTabTitleStyleDefault;
    self.pageTabView.indicatorStyle = XXPageTabIndicatorStyleStretch;
    self.pageTabView.indicatorWidth = YLScreenW / 2.0 - 20;
    [self.view addSubview:self.pageTabView];
}

- (void)pageTabViewDidEndChange {
//    NSLog(@"#####%d", (int)self.pageTabView.selectedTabIndex);
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
